from giga_chat import Chat
from document import Doc
import os


async def get_and_save_document(chat_id: int, applications: str) -> str:
    document = Doc()
    for app in applications:
        chat = Chat()
        response = chat.send_message(app)
        document.add_text(response)

    if not os.path.exists(f"files/{chat_id}"):
        os.makedirs(f"files/{chat_id}")
    return document.save(f"{chat_id}/Акты внедрения")
